---
title: useRef
---

import useRef from '../../../examples/files/hooks/useRef.js'

With `useRef` we can create and update a single mutable value that exists for the lifetime of the component instance.

After assigning the ref to a variable, we use `.current` to access the mutable value.

---

## Example

In this example, we store the return value of `setInterval`, which is an interval id, so that we can later call `clearInterval`.

> We'll see more examples of `useRef` in the [Animated](/app/animation/animated) API section.

<Example code={useRef} />
